<template>
    <div id="enterprise" style="width: 421px;height: 290px; background: #0F373F; "></div>
</template>

<script>
import {QueryCompanyStatistics} from "../../../network/companyApi";

export default {
  name: "companyType",
  methods: {
    myEcharts() {
// 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('enterprise'));
      QueryCompanyStatistics({showMessage: 1}).then(res => {
        let c = res.data.countGroupByType;
        let data = [];
        for (let i = 0; i < c.length; i++) {
          data.push({
            value: c[i].count,
            name: c[i].type,
          });
        }
        myChart.setOption({
          tooltip: {
            trigger: 'item'
          },
          legend: [
            {
              orient: 'horizontal',
              // top: 20,
              textStyle: {
                fontSize: '11px',
                color: '#ffffff',
              },
              data

            },

          ],

          series: [{
            // name: '企业类型',
            type: 'pie',
            radius: ['40%', '75%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: '#fff',
              borderWidth: 2,
            },
            label: {
              show: true,
              formatter: '{c}',
              position: 'inner',
              color: '#ffffff'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '20',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data
          }]
        })
      }).catch(() => {
        // this.myEcharts()
      })
    },
  },
  mounted() {
    this.myEcharts();
  },
}
</script>

<style scoped>
/*#enterprise {*/
/*  border-radius: 5px;*/
/*}*/
</style>